package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;


@Data
@Entity
@Table(name = "PRD_CONT_CHARGE")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PrdContCharge implements Serializable {

    private static final long serialVersionUID = 1193751485507789049L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "PRD_CONT_CHARGE_SEQ")
    @SequenceGenerator(name = "PRD_CONT_CHARGE_SEQ", allocationSize = 1, sequenceName = "PRD_CONT_CHARGE_SEQ")
    private Long id;

    /**
     *  节目id
     */
    @Column(name = "PRD_CONT_ID")
    private String prdContId;

    /**
     *   节目名称
     */
    @Column(name="PRD_CONT_NAME")
    private String prdContName;

    /**
     *   商品包id
     */
    @Column(name="PRD_INFO_ID")
    private String prdInfoId;

    /**
     *   产品属性
     */
    @Column(name="PRODUCT_PROP")
    private String productProp;

    /**
     *   计费id
     */
    @Column(name="CHARGE_ID")
    private String chargeId;

    /**
     *   计费名称
     */
    @Column(name="CHARGE_NAME")
    private String chargeName;

    /**
     *   计费类型
     */
    @Column(name="CHARGE_TYPE")
    private String chargeType;

    /**
     *   下载次数
     */
    @Column(name="DOWN_COUNT")
    private int downCount;

    /**
     *   渠道包id
     */
    @Column(name="CHANNELPKG_ID")
    private String channalPkgId;

    /**
     *   编码分类
     */
    @Column(name="MEDIA_RATE")
    private String mediaRate;

    /**
     *   码率计费
     */
    @Column(name="RATE_CHARGE_ID")
    private String rateChargeId;

    /**
     *   状态
     */
    @Column(name="STATUS")
    private String status;

    /**
     *   终端
     */
    @Column(name="TERMINAL_SYSTEM")
    private String terminalSystem;

    /**
     *   创建时间
     */
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(name="CREATE_TIME")
    private java.time.LocalDateTime createTime;

    /**
     *   更新时间
     */
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(name="UPDATE_TIME")
    private java.time.LocalDateTime updateTime;

    /**
     *   创建人
     */
    @Column(name="CREATOR")
    private String creator;

    public static void putTimeAndUser(PrdContCharge prdContCharge) {
        if (prdContCharge.getId() == null) {
            prdContCharge.setCreator(CurrentUser.currUserName());
            prdContCharge.setCreateTime(java.time.LocalDateTime.now());
        }
        prdContCharge.setUpdateTime(java.time.LocalDateTime.now());
    }
}
